﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
<link href="../tablecloth/tablecloth.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="../tablecloth/tablecloth.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>

<?php	

	include("../inc/joomlaInt_admin.php");
	include("../inc/inc_configuration.php");

if ($jUser==0)
{
	echo "Bitte zuerst einloggen!";
}
else
{	
	
	$q="SELECT gid FROM $tbl_users WHERE id=$jUser";
					$qe=mysql_query($q);
					$qeo=mysql_fetch_object($qe);
					
					$gid=$qeo->gid;
					
					if ($gid!=$admingroup)
					{
						echo "Du bist kein Admin!";
						break;
					}
	echo "<h1>Spiel werten</h1>";
	
	echo "<table>
			<tr>
				<th>User</th>
				<th>Datum</th>
				<th>Text</th>
			</tr>";
	
	$match=$_GET["id"];
	
	//Get Team ids
	
	$tq="SELECT homeT, guestT FROM $tbl_matches WHERE id=$match";
	$tqe=mysql_query($tq);
	$tqeo=mysql_fetch_object($tqe);
	
	$tHi=$tqeo->homeT;
	$tGi=$tqeo->guestT;
	
	
	$mq=	"SELECT f.content, u.username, f.date AS datum FROM $tbl_forderungen f, $tbl_users u WHERE f.userId=u.id AND f.matchId=$match";
	
	$mqe=mysql_query($mq);
				
	while ($row=mysql_fetch_object($mqe))
	{
		$content=$row->content;
		$un=$row->username;
		$datum=$row->datum;
		
		$playdate=date("d.m.y - H:i",$datum);
		
		echo "	<tr>
					<td>$un</td>
					<td>$playdate</td>
					<td>$content</td>					
				</tr>";	
	}
	
	
	//Eintragen
	
	//Combinations suchen
		$uHSql="	SELECT username AS uHn, c.id AS hC FROM $tbl_combinations c, $tbl_users u
						WHERE
						(c.teamId=$tHi) AND
						(c.active=1) AND
						(c.userId=u.id)";
		$uGSql="	SELECT username AS uGn, c.id AS gC FROM $tbl_combinations c, $tbl_users u
				WHERE
				(c.teamId=$tGi) AND
				(c.active=1) AND
				(c.userId=u.id)";
				
		$uHq = mysql_query($uHSql);
		$uGq = mysql_query($uGSql);

		
		$cH = mySQL_num_rows($uHq);
		$cG = mySQL_num_rows($uGq);
		
		if ($cH == 1)
		{
			$uHnq = mysql_fetch_object($uHq);
			$uHn = $uHnq->uHn;
			$uHid = $uHnq->hC;
		}
		else
		{
			$uHn = "(-)";
			$uHid = 0;
		}
		
		if ($cG == 1)
		{
			$uGnq = mysql_fetch_object($uGq);
			$uGn = $uGnq->uGn;
			$uGid = $uGnq->gC;
		}
		else
		{
			$uGn = "(-)";
			$uGid=0;
		}
		
	echo "<tr><th colspan='3'></th></tr></table>";
	
	echo "	<form action='spiel_werten_v.php' method='post'>
			<table>
				<tr><th colspan='3'></th></tr>
				<tr>
					<td>$uHn</td>
					<td><input name='heimT' type='text' size='30'><input name='heimC' type='hidden' value='",$uHid,"'></td>
				</tr>
				<tr>
					<td>$uGn:</td>
					<td><input name='gastT' type='text' size='30'><input name='gastC' type='hidden' value='",$uGid,"'></td>
				</tr>
				<tr>
					<td></td>
					<td><input name='match' type='hidden' value='",$match,"'><input type='submit' value='Werten' class='button anlegen'></td>
				</tr>
				<tr><th colspan='3'></th></tr>
			</table>
			</form>
			";
	
	echo "<br><br><center><a href='../admin/offene_spiele.php' class='button zurueck'>Zurück</a>";
}	
?>

</body>
</html>